﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using math.DTOs;

namespace math.DataAccess
{
    public class Queries
    {
        private StudentDBDataContext dbContext;
        public void SaveStudent(StudentInfo studInfo)
        {
            dbContext = new StudentDBDataContext(DBConStr);

            Student studObj = new Student();

            studObj.RollNo = studInfo.RollNo;
            studObj.Name = studInfo.Name;
            studObj.Age = studInfo.Age;

            dbContext.Students.InsertOnSubmit(studObj);

        }
        public void DBSubmit()
        {
            if (dbContext != null)
            {
                dbContext.SubmitChanges();
                dbContext.Dispose();
            }
        }
        private string DBConStr
        {
            get { return ConfigurationManager.ConnectionStrings["StudentDBCon"].ToString(); }
        }
    }
}
